<style type="text/css">
h3.token
{
	margin-top:0px;
	margin-bottom:0px;
	padding-bottom:0px;
	padding-top:0px;
}
</style>

<?php if( strlen($tinfo['token']) < 5 ): ?>
<!-- 从未创建过token -->

<div class="alert ">
<div class="row-fluid">	
<div class="span10"><?=__('PL_SIMPLE_TOKEN_EXPLAIN')?></div>
<div class="span2"><a href="javascript:stoken_create();void(0);" class="btn btn-primary"><?=__('PL_SIMPLE_TOKEN_TO_ACTIVE')?></a></div>
</div>
</div>


<?php elseif( intval( $tinfo['on'] ) != '1' ): ?>
<!-- 创建过token，但关闭了 -->
<div class="alert alert-error">
<div class="row-fluid">	
<div class="span10"><h3 class="token"><?=__('PL_SIMPLE_TOKEN_STOPPED',$tinfo['token']);?></h3></div>
<div class="span2"><a href="javascript:stoken_reopen();void(0);" class="btn btn-primary"><?=__('PL_SIMPLE_TOKEN_TO_ACTIVE')?></a></div>
</div>

</div>
<?php else: ?>
<!-- 创建了token，并正在使用 -->
<div class="alert alert-info">
<div class="row-fluid">	
<div class="span8"><h3 class="token"><?=__('PL_SIMPLE_TOKEN_ACTIVE',$tinfo['token']);?></h3></div>
<div class="span2"><a href="javascript:stoken_update();void(0);" class="btn btn-danger"><?=__('PL_SIMPLE_TOKEN_RESET')?></a></div>
<div class="span2"><a href="javascript:stoken_close();void(0);" class="btn btn-warning"><?=__('PL_SIMPLE_TOKEN_STOP')?></a></div>
</div>
</div>

<div class="row-fluid">	
<div class="span4">
<?=__('PL_SIMPLE_TOKEN_DOC_TODOLIST',$tinfo['token'])?><br/>
<?=__('PL_SIMPLE_TOKEN_DOC_UNREAD_MESSAGE',$tinfo['token'])?>
</div>	
<div class="span4">
<?=__('PL_SIMPLE_TOKEN_DOC_MEMBERS',$tinfo['token'])?><br/>
<?=__('PL_SIMPLE_TOKEN_DOC_FEED',$tinfo['token'])?>

<br/>

</div>	
<div class="span4">
<?=__('PL_SIMPLE_TOKEN_DOC_MORE',c('teamtoy_url'))?>
</div>	




</div>

<?php endif; ?>
<script type="text/javascript">
function stoken_create(update)
{
	var url = '?c=plugin&a=simple_token&do=create';
	$.post( url , {} , function( data )
	{
		if( data == 'done' )
		{
			/*if( update )
				alert( 'Token已经重置' );
			else	
				alert( 'Token创建成功' );
			*/
			show_float_box( '<?=__('PL_SIMPLE_TOKEN_TITLE')?>' , '?c=plugin&a=simple_token');
		}
		else
			alert( '<?=__('PL_SIMPLE_TOKEN_CREATE_ERROR')?>' );
	} );
}

function stoken_update()
{
	if( confirm( '<?=__('PL_SIMPLE_TOKEN_RESET_CONFIRM')?>' ) )
		return stoken_create(1);
	
}

function stoken_close()
{
	var url = '?c=plugin&a=simple_token&do=close';
	$.post( url , {} , function( data )
	{
		if( data == 'done' )
		{
			//alert( 'Token已停用' );
			show_float_box( '<?=__('PL_SIMPLE_TOKEN_TITLE')?>' ,'?c=plugin&a=simple_token');
		}
		else
			alert( '<?=__('PL_SIMPLE_TOKEN_CREATE_ERROR')?>' );
	} );
}

function stoken_reopen()
{
	var url = '?c=plugin&a=simple_token&do=reopen';
	$.post( url , {} , function( data )
	{
		if( data == 'done' )
		{
			//alert( 'Token已启用' );
			show_float_box( '<?=__('PL_SIMPLE_TOKEN_TITLE')?>' ,'?c=plugin&a=simple_token');
		}
		else
			alert( '<?=__('PL_SIMPLE_TOKEN_CREATE_ERROR')?>' );
	} );
}
</script>